import axios from 'axios'

const instance = axios.create({
  baseURL: 'https://gitee.com/api',
  timeout: 10000
})

instance.interceptors.request.use(
  (config) => {
    return config
  },
  (error) => {
    return Promise.reject(error)
  }
)

instance.interceptors.response.use(
  (res) => {
    return res
  },
  (error) => {
    if(error.response.status === 403) {
      // 超出访问限制， 这里不做抛出异常，交给实际接口处理
      return Promise.resolve(error.response)
    }
    return Promise.reject(error)
  }
)

export default instance
